<template>
  <table>
    <tr>
      <td><input type="text" v-model="name"></td>
      <td><input type="text" v-model="shouji"></td>
      <td><input type="text" v-model="chanpin"></td>
      <button @click="add">确定订单</button>
    </tr>
  </table>
</template>

<script>
    export default {
        name: "dan",
      data:function () {
        return{
          name:'',
          shouji:'',
          chanpin:'',
        }
      },
      mounted() {
          this.name = localStorage.getItem('name')
          this.shouji = localStorage.getItem('shouji')
          this.chanpin = localStorage.getItem('chanpin')
      },
      methods:{
          add:function () {
            let formdata = new FormData()
            formdata.append('name', this.name)
            formdata.append('shouji', this.shouji)
            formdata.append('text', this.chanpin)

            this.axios({
              url:'http://127.0.0.1:8000/dan/',
              method:'post',
              data:formdata,
            }).then(res=>{
              if(res.data.code==200){
                console.log(res.data.message)
                this.$router.push('dingdan')
              }
            })
          }
      }
    }
</script>

<style scoped>

</style>
